//personalCenter.js,获取应用实例
const user = require('../../utils/getUserinfo.js')
const app = getApp()
Page({
  data: {
    loginStr:'',
    regist:false,
    memberStr:'会员',
    headimg: [
      {url: '../imgs/swiper/swp1.jpg'},
      {url: '../imgs/swiper/swp2.jpg'},
      {url: '../imgs/swiper/swp3.jpg'}
    ]

  },

   regist: function () {
    wx.navigateTo({
      url: '../regist/regist',
    })
  },

//跳到支付（购物车)页面
memberStatus: function () {
  //这里要检测用户是否已经登录，如果没有测不允许激活会员
  if(app.globalData.openId==''){
    //此处给出提示，要求用户登录
    wx.showModal({
      title: '恭喜您',
      content: '已成功登录，祝您学习愉快！',
      showCancel: false, //是否显示取消按钮-----》false去掉取消按钮
      confirmText: "确定",    //默认是“确定”
      confirmColor: 'skyblue', //确定文字的颜色
      success: function (res) {
        if (res.confirm) {
          wx.navigateTo({
            url: '../login/login',
          })

        }
      } //success

    })  //showModal 

  } else {
   //此处完成激活
    user.getUserinfo().then(function (data) {
      console.log(data);
      wx.navigateTo({
        url: "'../payment/payment?fromPass='tab'",
      })

    }, function (error) {
      // failure

    });
  }


   
  
},

  onShow: function () {  
    this.setData({
      loginStr: app.globalData.loginStr,
    })
  },

//事件处理函数
bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  
  clickMe() {
    this.setData({ message: 'Hello World' })
    wx.scanCode({
      success: (res) => {
        console.log(res)
      }
    }) 
  
  },

 onLoad: function() {
   
},
 
})